package com.zt.springcloud.controller;

import cloud.zt.springboot.utils.ResultUtils;
import com.zt.springcloud.entity.Vo.OrderListVo;
import com.zt.springcloud.service.OrderService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author RedReins
 * @version 1.0
 * @description: TODO
 * @date 2021/9/11 18:25
 */

@RestController
public class OrderController {
    @Resource
    private OrderService orderService;

    @RequestMapping(value = "/createOrder",method = RequestMethod.POST)
    public ResultUtils<?> doOrder(@RequestBody String reqData) {
        return ResultUtils.success(orderService.createOrder(reqData));
    }

    /*
     * 查询用户所有订单
     * */
    @RequestMapping(value = "/orderList",method = RequestMethod.POST)
    public ResultUtils<List<OrderListVo>> getUserAllOrder(){
        return ResultUtils.success(orderService.getUserAllOrder());
    }
    /*
     * 删除订单中的商品
     * */
    @RequestMapping(value = "/orderDelete/{orderId}",method = RequestMethod.DELETE)
    public ResultUtils<?> deleteOrderItem(@PathVariable("orderId") String orderId){
        return ResultUtils.success(orderService.deleteOrderItem(orderId));
    }

}
